package de.itagile.hypersphere

import de.itagile.hypersphere.EntityTemplate
import de.itagile.hypersphere.mock.EntityFieldTemplateMock
import de.itagile.hypersphere.mock.EntityRelationshipTemplateMock
class EntityTemplateStartsWithRootTest extends GroovyTestCase {
	
	def fieldMock = new EntityFieldTemplateMock()
	def relationshipMock = new EntityRelationshipTemplateMock()
	
	def entityTemplate = new EntityTemplate(
			name: "Book",
			ePackage: "ejbs",
			table: "BOOK_TABLE",
			fieldTemplate: fieldMock,
			relationshipTemplate: relationshipMock)
	
	def result = entityTemplate.root()
	
	void testDeclaration() {
		assertEquals("package ejbs;", result[0])
		assertEquals("import javax.persistence.*;", result[1])
		assertEquals("@Entity", result[2])
		assertEquals('@Table(name = "BOOK_TABLE")', result[3])
	}
	
	void testGeneratesFields() {
		assertTrue(fieldMock.fieldsGenerated())
	}
	
	void testGeneratedRelationships() {
		assertTrue(relationshipMock.relationshipsGenerated())
	}
}